package com.ie.service.before;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ie.common.http.ResponseResult;
import com.ie.entity.FocusEntity;
import com.ie.entity.GoodsEntity;
import org.springframework.stereotype.Service;
import com.ie.mapper.before.FocusMapper;
import com.ie.service.before.FocusService;
import com.ie.entity.FocusEntity;

import java.util.Date;
import java.util.Map;


@Service
public class FocusServiceImpl extends ServiceImpl<FocusMapper, FocusEntity> implements FocusService{
    @Override
    public ResponseResult<Map<String, Object>> addFocus(FocusEntity focusentity) {
        Long count = lambdaQuery().eq(FocusEntity::getBusertableId, focusentity.getBusertableId())
                .eq(FocusEntity::getGoodstableId, focusentity.getGoodstableId()).count();
        if(count > 0){
            return ResponseResult.getMessageResult(null, "A001");
        }
        focusentity.setFocustime(new Date());
        if(save(focusentity)){
            return ResponseResult.getMessageResult(null, "A002");
        }
        return ResponseResult.getMessageResult(null, "A003");
    }

    @Override
    public ResponseResult<Map<String, Object>> iPageMyFocusGoods(GoodsEntity goodsEntity) {
        return null;
    }
}
